﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Game_Engine
{
    public class Collider : Component   
    {
        public virtual bool Collides(Collider collider, out Vector3 normal)     //A collider class is a pathway to Newton's Third Law
        {
            normal = Vector3.Zero;
            return false;
        }

        public Ray toObject(Ray ray)   //Converts a ray to Object coordinates of a given collider for collision testing usually
        {
            Matrix worldInverted = Matrix.Invert(this.Transform.World);
            ray.Position = Vector3.Transform(ray.Position, worldInverted);
            ray.Direction = Vector3.TransformNormal(ray.Direction, worldInverted);

            return ray;
        }

        public virtual float? Intersects(Ray ray)   //The question mark after the return type denotes the possibility of null as a return value
        {
            return null;
        }
    }
}
